/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.engine.core.val;

import com.inspur.edp.bef.bizentity.GspBizEntityObject;
import com.inspur.edp.cef.designtime.api.IGspCommonField;
import com.inspur.edp.formserver.viewmodel.GspViewModel;

import java.util.HashMap;

public class ValComponentManager {
    private static HashMap<String, String> compMap = new HashMap<>();//VO校验规则ID和UDT对应关系

    static {
        //密级
        compMap.put("ae9e852b-56d8-4eb0-afc0-62348f0eca60", "bd050131-e9ed-47e8-b08f-533b28928c5f");//密级校验规则和密级UDT ID
    }

    /**
     * 是否内置udt校验
     * @param componentId
     * @return
     */
    public static boolean isBuildInValidation(String componentId){
        return compMap.containsKey(componentId);
    }

    public static String getPropName(GspBizEntityObject gspBizEntityObject, String componentId){
        String propName = "";
        for(IGspCommonField gspCommonField: gspBizEntityObject.getContainElements()){
            if(gspCommonField.getIsUdt() && gspCommonField.getUdtID().equals(compMap.get(componentId))){
                return gspCommonField.getLabelID();
            }
        }
        return propName;
    }
}
